//
//  QPayStyleCell.m
//  QoilPublic
//
//  Created by 杨凯 on 16/7/7.
//  Copyright © 2016年 杨凯. All rights reserved.
//

#import "QPayStyleCell.h"

@interface QPayStyleCell()

@property (weak, nonatomic) IBOutlet UIImageView *iconImage;

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleConstr;

@property (weak, nonatomic) IBOutlet UILabel *subTitleLabel;

@property (weak, nonatomic) IBOutlet UIButton *chooseBtn;

@property (weak, nonatomic) IBOutlet UIImageView *lineImage;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *lineConstr;

@end
@implementation QPayStyleCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.lineImage.backgroundColor = [QColorUtility defaultLineColor];
    self.lineConstr.constant = 0.5;
}

- (void)setIndexPath:(NSIndexPath *)indexPath{
    _indexPath = indexPath;
    
    if(_indexPath.section == 1){
        if(_index == _indexPath.row){
            [self.chooseBtn setImage:[UIImage imageNamed:@"payselect_image"] forState:UIControlStateNormal];
        }else{
            [self.chooseBtn setImage:[UIImage imageNamed:@"paynoselect_image"] forState:UIControlStateNormal];
        }
    }else{
        if(_index == 4){
            [self.chooseBtn setImage:[UIImage imageNamed:@"payselect_image"] forState:UIControlStateNormal];
        }else{
            [self.chooseBtn setImage:[UIImage imageNamed:@"paynoselect_image"] forState:UIControlStateNormal];
        }
    }
    
    if(_indexPath.row == 0 && _indexPath.section == 1){
        _iconImage.hidden = YES;
        _titleConstr.constant = 15;
        _titleLabel.text = @"余额支付";
        _subTitleLabel.hidden = NO;
        _subTitleLabel.text = [NSString stringWithFormat:@"(当前余额:￥%@)",[QUserInfo sharedInfo].loginModel.balance];
        _subTitleLabel.textColor = [QColorUtility defaultDeepGrayColor];
    }else if (_indexPath.row == 1 && _indexPath.section == 1){
        _iconImage.image = [UIImage imageNamed:@"weixin_image"];
        _iconImage.hidden = NO;
        _titleConstr.constant = 40;
        _titleLabel.text = @"微信支付";
        _subTitleLabel.hidden = YES;

    }else if (_indexPath.row == 2 && _indexPath.section == 1){
        _iconImage.image = [UIImage imageNamed:@"zhifubao_image"];
        _iconImage.hidden = NO;
        _titleConstr.constant = 40;
        _titleLabel.text = @"支付宝支付";
        _subTitleLabel.hidden = YES;
    }else if (_indexPath.row == 3 && _indexPath.section == 1){
        _iconImage.hidden = NO;
        _iconImage.image = [UIImage imageNamed:@"oilpay_image"];
        _titleConstr.constant = 40;
        _titleLabel.text = @"油到付款";
        _subTitleLabel.hidden = NO;
        _subTitleLabel.text = @"";
        _subTitleLabel.textColor = [QColorUtility defaultDeepGrayColor];
    }else if(_indexPath.section == 2){
        _iconImage.image = [UIImage imageNamed:@"bossPay_image"];
        _iconImage.hidden = NO;
        _titleConstr.constant = 40;
        _titleLabel.text = @"老板付款";
        _subTitleLabel.hidden = YES;
    }
}

- (void)setCIndexPath:(NSIndexPath *)cIndexPath{
    _cIndexPath = cIndexPath;
    
    if(_index == _cIndexPath.row){
        [self.chooseBtn setImage:[UIImage imageNamed:@"payselect_image"] forState:UIControlStateNormal];
    }else{
        [self.chooseBtn setImage:[UIImage imageNamed:@"paynoselect_image"] forState:UIControlStateNormal];
    }
    if(_cIndexPath.row == 0){
        _iconImage.image = [UIImage imageNamed:@"weixin_image"];
        _iconImage.hidden = NO;
        _titleConstr.constant = 40;
        _titleLabel.text = @"微信支付";
        _subTitleLabel.hidden = YES;
    }else if(_cIndexPath.row == 1){
        _iconImage.image = [UIImage imageNamed:@"zhifubao_image"];
        _iconImage.hidden = NO;
        _titleConstr.constant = 40;
        _titleLabel.text = @"支付宝支付";
        _subTitleLabel.hidden = YES;
    }
}

@end
